package com.wiselink.fastbox.orderplacement;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.wiselink.exception.FastBoxException;
import com.wiselink.fastbox.FastBoxBaseAPI;
import lombok.Getter;
import lombok.ToString;

import java.util.*;

/**
 * 订单注册
 * 注：该对象不可复用，原因是 成员变量vos是当次订单注册的结果，如需重新注册，请重新创建对象
 */
public class OrderRegistration extends FastBoxBaseAPI {

    private final List<BO> bos;

    private final List<ResultVO> vos = new ArrayList<>();

    public OrderRegistration(List<BO> bos) {
        this.bos = bos;
    }

    @Override
    public String getPath() {
        return "/api/order/add/resale";
    }

    @Override
    public Map<String, String> getRequestParam() {
        return Collections.emptyMap();
    }

    @Override
    public String getRequestData() {
        List<Map<String, String>> requestDataList = new ArrayList<>(bos.size());
        for (BO bo : bos) {
            Map<String, String> data = new HashMap<>();
            // 销售公司名称
            data.put("seller_name", bo.getSeller_name());
            // 卖家订单日期 格式 YYYY-MM-DD
            data.put("ord_date", bo.getOrd_date());
            // 合并订单号（合并订单无法通过海外配送应用程序处理。此号码将发送到卖家的订单号。）
            data.put("ord_bundle_no", bo.getOrd_bundle_no());
            // 参考编号（可代替 FB 发票号码）
            data.put("reference_order_no", bo.getReference_order_no());
            // 实际付款金额
            data.put("actual_payment", bo.getActual_payment());
            // 货币(KRW/USD/JPY/CNY/EUR)（韩元/美元/日元/人民币/欧元）
            data.put("currency_code", bo.getCurrency_code());
            // 会员折扣金额
            data.put("membership_discount_amount", bo.getMembership_discount_amount());
            // 每笔订单优惠券折扣金额
            data.put("coupon_discount_price", bo.getCoupon_discount_price());
            // 运费折扣
            data.put("shipping_fee_discount_amount", bo.getShipping_fee_discount_amount());
            // App订单折扣金额
            data.put("app_discount_amount", bo.getApp_discount_amount());
            // 已使用积分数量
            data.put("points_spent_amount", bo.getPoints_spent_amount());
            // 最终使用的储蓄金额
            data.put("final_points_spent_amount", bo.getFinal_points_spent_amount());
            // 押金、信用使用金额
            data.put("credits_spent_amount", bo.getCredits_spent_amount());
            // 运费优惠券折扣金额
            data.put("coupon_shipping_fee_amount", bo.getCoupon_shipping_fee_amount());
            // 发货国家代码 (KR, CN, JP)
            data.put("country_domain", bo.getCountry_domain());
            // 收件人姓名
            data.put("receiver_name", bo.getReceiver_name());
            // 收件人姓名 2（运送至日本时必填）
            data.put("receiver_name_voice", bo.getReceiver_name_voice());
            // 英文收件人姓名
            data.put("receiver_name_eng", bo.getReceiver_name_eng());
            // 收件人座机
            data.put("receiver_phone", bo.getReceiver_phone());
            // 收件人的手机号码
            data.put("receiver_cell", bo.getReceiver_cell());
            // 收件人邮箱
            data.put("receiver_email", bo.getReceiver_email());
            // 收货邮政编码
            data.put("receiver_zipcode", bo.getReceiver_zipcode());
            // 收货地址
            data.put("receiver_address1", bo.getReceiver_address1());
            // 详细收货地址 1
            data.put("receiver_address2", bo.getReceiver_address2());
            // 详细收货地址 2
            data.put("receiver_address3", bo.getReceiver_address3());
            // 运费
            data.put("ship_fee", bo.getShip_fee());
            // 运费预付 (T/F)
            data.put("is_prepaid_ship_fee", bo.getIs_prepaid_ship_fee());
            // 发货信息
            data.put("delivery_message", bo.getDelivery_message());
            // 首选配送公司
            data.put("want_deliverer", bo.getWant_deliverer());
            // 首选配送日期
            data.put("want_date", bo.getWant_date());
            // 首选配送时间
            data.put("want_time", bo.getWant_time());
            // 后付费（T/F）
            data.put("is_postpaid", bo.getIs_postpaid());
            // 后付费实际支付金额
            data.put("postpaid_actual_payment", bo.getPostpaid_actual_payment());
            // 后付费费用
            data.put("postpaid_fee", bo.getPostpaid_fee());
            // 后付费货币(KRW/USD/JPY/CNY)
            data.put("postpaid_currency_code", bo.getPostpaid_currency_code());
            // 订单路径
            data.put("order_place_id", bo.getOrder_place_id());
            // 订单路径名称（如果 order_place_id 为自助服务代码，则为必填项）
            data.put("order_place_name", bo.getOrder_place_name());
            // 其他市场信息
            data.put("market_order_info", bo.getMarket_order_info());
            // 身份证
            data.put("ship_identity", bo.getShip_identity());
            // 税务识别号
            data.put("cdremark", bo.getCdremark());
            // 商店品牌名称（仅限英文字符和数字）
            data.put("resale_brand_name", shop.getMallId());
            // 商店代表姓名
            data.put("resale_ceo_name", shop.getShopName());
            // 代表企业名称
            data.put("resale_company_name", shop.getSellerName());
            // 企业注册号
            data.put("resale_shop_biz_no", shop.getMallId());
            // 店铺英文地址
            data.put("resale_shop_address_eng", shop.getAddressEng());
            // 是否使用出口报关（P/F）
            data.put("resale_use_export_declare", bo.getResale_use_export_declare());
            // 出口申报标准金额（出口申报用途为 P 时必填）• 允许值：S/D
            data.put("resale_declare_price_type", bo.getResale_declare_price_type());
            // 海关清关代码（出口报关用途为 P 时必填）海关清关代码
            data.put("resale_customs_id", bo.getResale_customs_id());
            // 出口报关托运人信息邮政编码（出口报关用途为 P 时必填）邮政编码
            data.put("resale_declare_zipcode", bo.getResale_declare_zipcode());
            // 出口报关托运人信息地址（出口报关用途为 P 时必填）（韩语）
            data.put("resale_declare_address1", bo.getResale_declare_address1());
            // 出口报关托运人信息详细地址（出口报关用途为 P 时必填）详细地址（韩语）
            data.put("resale_declare_address2", bo.getResale_declare_address2());
            // 发件人姓名• 卖家名称或客户公司名称
            data.put("resale_sender_name", bo.getResale_sender_name());
            // EMS 产品分类（内容类型）内容名称 • 如果为空，则在产品标题中存储第一个海关类别值。
            // 标签上的内容名称 *在快速包装盒中，EMS 发货时使用代表性内容名称。
            data.put("resale_ems_goods_name", bo.getResale_ems_goods_name());
            // EMS HS 编码• 如果为空，请填写产品标题中的第一个 HS 编码。
            //标签上的 HS 编码。*在 Fastbox 中，EMS 货件将使用对应的 HS 编码进行处理。
            data.put("resale_ems_hscode", bo.getResale_ems_hscode());
            // EMS 发货地（输入国家/地区代码）• 如果为空，请保存为 KR
            data.put("resale_ems_making_country", bo.getResale_ems_making_country());
            // 销售地点网址
            data.put("resale_shop_url", bo.getResale_shop_url());
            // • 船运公司付款类型 (DDP/DDU)• 如果为空，则选择 DDP
            data.put("resale_delivery_duty_type", bo.getResale_delivery_duty_type());

            List<Map<String, String>> itemList = new ArrayList<>(bo.getItems().size());
            for (BO.ItemBO itemBO : bo.getItems()) {
                Map<String, String> itemInfo = new HashMap<>();
                // 卖家订单号
                itemInfo.put("seller_ord_code", itemBO.getSeller_ord_code());
                // 卖家商品编号
                itemInfo.put("seller_ord_item_code", itemBO.getSeller_ord_item_code());
                // 商店商品代码
                itemInfo.put("item_code", itemBO.getItem_code());
                // 商店产品代码
                itemInfo.put("prd_code", itemBO.getPrd_code());
                // 商品条形码
                itemInfo.put("item_barcode", itemBO.getItem_barcode());
                // 产品名称
                itemInfo.put("input_prd_name", itemBO.getInput_prd_name());
                // 商品名称
                itemInfo.put("input_item_name", itemBO.getInput_item_name());
                // 英文产品名称
                itemInfo.put("prd_name_eng", itemBO.getPrd_name_eng());
                // 产品材质（日本发货必填）
                itemInfo.put("material", itemBO.getMaterial());
                // 面料（日本发货必填）
                itemInfo.put("cloth_material", itemBO.getCloth_material());
                // 数量
                itemInfo.put("ord_qty", itemBO.getOrd_qty());
                // 售价
                itemInfo.put("selling_price", itemBO.getSelling_price());
                // 可选价格
                itemInfo.put("option_price", itemBO.getOption_price());
                // 产品折扣金额
                itemInfo.put("discount_price", itemBO.getDiscount_price());
                // 优惠券折扣金额（产品）
                itemInfo.put("coupon_item_discount_price", itemBO.getCoupon_item_discount_price());
                // 应用产品折扣金额
                itemInfo.put("app_item_discount_amount", itemBO.getApp_item_discount_amount());
                // HS 编码
                itemInfo.put("hs_code", itemBO.getHs_code());
                // 公司产品名称
                itemInfo.put("private_prd_name", itemBO.getPrivate_prd_name());
                // 公司产品名称
                itemInfo.put("private_item_name", itemBO.getPrivate_item_name());
                // 海关类别名称
                itemInfo.put("prd_category", itemBO.getPrd_category());
                // 海关产品名称
                itemInfo.put("prd_category_info", itemBO.getPrd_category_info());
                itemInfo.put("is_gift", itemBO.getIs_gift());
                itemInfo.put("item_location_code", itemBO.getItem_location_code());
                itemInfo.put("seller_ord_item_no", itemBO.getSeller_ord_item_no());
                itemList.add(itemInfo);
            }
            data.put("item_list", JSON.toJSONString(itemList));

            requestDataList.add(data);
        }
        return JSON.toJSONString(requestDataList);
    }

    @Override
    public void processResponseResult(JSONObject jsonResult) {
        log.debug(">>>处理 下单 响应结果<<<");
        JSONObject meta = jsonResult.getJSONObject("meta");
        Integer code = meta.getInteger("code");
        String message = meta.getString("message");
        switch (code) {
            case 200:
                JSONArray response = jsonResult.getJSONArray("response");
                log.debug("下单成功 response: {}", response);
                for (int i = 0; i < response.size(); i++) {
                    JSONObject item = response.getJSONObject(i);
                    ResultVO resultVO = new ResultVO();
                    resultVO.setOrdBundleNo(item.getString("ord_bundle_no"));
                    resultVO.setFbInvoiceNo(item.getString("fb_invoice_no"));
                    resultVO.setOrdNo(item.getString("ord_no"));
                    resultVO.setResult(item.getBoolean("result"));
                    resultVO.setResultReason(item.getJSONArray("result_reason"));
                    resultVO.setDeliveryType(item.getString("delivery_type"));
                    resultVO.setInvoiceNo(item.getString("invoice_no"));
                    resultVO.setInvoicePdfUrl(item.getString("invoice_pdf_url"));
                    resultVO.setIsCustom(item.getBoolean("is_custom"));
                    resultVO.setMarketOrdCode(item.getString("market_ord_code"));
                    resultVO.setReceiverName(item.getString("receiver_name"));
                    resultVO.setMarketSellerName(item.getString("market_seller_name"));
                    vos.add(resultVO);
                }
                break;
            case 440:
                throw new FastBoxException("必需参数错误：缺失或无效值. message:" + message);
            case 500:
                throw new FastBoxException("内部处理错误. message:" + message);
            case 600:
                throw new FastBoxException("未知错误（未定义错误）. message:" + message);
            default:
                throw new FastBoxException("下单失败 code. message:" + message);
        }
    }

    /**
     * 获取订单注册结果
     *
     * @return List<ResultVO>
     */
    public List<ResultVO> getResult() {
        log.debug("获取订单注册解析结果 {}", vos);
        return vos;
    }

    /**
     * 订单注册结果视图
     */
    public static class ResultVO {
        /**
         * 合浦号码
         */
        private String ordBundleNo;
        /**
         * DeHub 发票号码
         */
        private String fbInvoiceNo;
        /**
         * DeHub 订单（装运指示）编号
         */
        private String ordNo;
        /**
         * 订单登记结果（true/false）
         */
        private Boolean result;
        /**
         * 订单注册失败失败原因
         */
        private JSONArray resultReason;
        /**
         * 配送类型（FB：快速箱，SD：私人物流）
         */
        private String deliveryType;
        /**
         * 运输公司发票号码（仅适用于内部物流）
         */
        private String invoiceNo;
        /**
         * 配送公司发票 PDF 链接（仅限自营物流）
         */
        private String invoicePdfUrl;
        /**
         * 是否可以定制发票（true/false）（仅适用于内部物流）
         */
        private Boolean isCustom;
        /**
         * 市场发票号码（仅限自营物流）
         */
        private String marketOrdCode;
        /**
         * 收件人姓名（仅限自营物流）
         */
        private String receiverName;
        /**
         * 市场卖家名称（仅限自营物流）
         */
        private String marketSellerName;

        public String getOrdBundleNo() {
            return ordBundleNo;
        }

        public void setOrdBundleNo(String ordBundleNo) {
            this.ordBundleNo = ordBundleNo;
        }

        public String getFbInvoiceNo() {
            return fbInvoiceNo;
        }

        public void setFbInvoiceNo(String fbInvoiceNo) {
            this.fbInvoiceNo = fbInvoiceNo;
        }

        public String getOrdNo() {
            return ordNo;
        }

        public void setOrdNo(String ordNo) {
            this.ordNo = ordNo;
        }

        public Boolean getResult() {
            return result;
        }

        public void setResult(Boolean result) {
            this.result = result;
        }

        public JSONArray getResultReason() {
            return resultReason;
        }

        public void setResultReason(JSONArray resultReason) {
            this.resultReason = resultReason;
        }

        public String getDeliveryType() {
            return deliveryType;
        }

        public void setDeliveryType(String deliveryType) {
            this.deliveryType = deliveryType;
        }

        public String getInvoiceNo() {
            return invoiceNo;
        }

        public void setInvoiceNo(String invoiceNo) {
            this.invoiceNo = invoiceNo;
        }

        public String getInvoicePdfUrl() {
            return invoicePdfUrl;
        }

        public void setInvoicePdfUrl(String invoicePdfUrl) {
            this.invoicePdfUrl = invoicePdfUrl;
        }

        public Boolean getIsCustom() {
            return isCustom;
        }

        public void setIsCustom(Boolean isCcustom) {
            isCustom = isCcustom;
        }

        public String getMarketOrdCode() {
            return marketOrdCode;
        }

        public void setMarketOrdCode(String marketOrdCode) {
            this.marketOrdCode = marketOrdCode;
        }

        public String getReceiverName() {
            return receiverName;
        }

        public void setReceiverName(String receiverName) {
            this.receiverName = receiverName;
        }

        public String getMarketSellerName() {
            return marketSellerName;
        }

        public void setMarketSellerName(String marketSellerName) {
            this.marketSellerName = marketSellerName;
        }

        @Override
        public String toString() {
            return "ResultVO{" +
                    "ordBundleNo='" + ordBundleNo + '\'' +
                    ", fbInvoiceNo='" + fbInvoiceNo + '\'' +
                    ", ordNo='" + ordNo + '\'' +
                    ", result=" + result +
                    ", resultReason=" + resultReason +
                    ", deliveryType='" + deliveryType + '\'' +
                    ", invoiceNo='" + invoiceNo + '\'' +
                    ", invoicePdfUrl='" + invoicePdfUrl + '\'' +
                    ", isCustom=" + isCustom +
                    ", marketOrdCode='" + marketOrdCode + '\'' +
                    ", receiverName='" + receiverName + '\'' +
                    ", marketSellerName='" + marketSellerName + '\'' +
                    '}';
        }
    }


    @ToString
    @Getter
    public static class BO {
        /**
         * 销售公司名称
         */
        private String seller_name;
        /**
         * 卖家订单日期 格式 YYYY-MM-DD
         */
        private String ord_date;
        /**
         * 合并订单号（合并订单无法通过海外配送应用程序处理。此号码将发送到卖家的订单号。）
         */
        private String ord_bundle_no;
        /**
         * 参考编号（可代替 FB 发票号码）
         */
        private String reference_order_no;
        /**
         * 实际付款金额
         */
        private String actual_payment;
        /**
         * 货币(KRW/USD/JPY/CNY/EUR)（韩元/美元/日元/人民币/欧元）
         */
        private String currency_code;
        /**
         * 会员折扣金额
         */
        private String membership_discount_amount;
        /**
         * 每笔订单优惠券折扣金额
         */
        private String coupon_discount_price;
        /**
         * 运费折扣
         */
        private String shipping_fee_discount_amount;
        /**
         * App订单折扣金额
         */
        private String app_discount_amount;
        /**
         * 已使用积分数量
         */
        private String points_spent_amount;
        /**
         * 最终使用的储蓄金额
         */
        private String final_points_spent_amount;
        /**
         * 押金、信用使用金额
         */
        private String credits_spent_amount;
        /**
         * 运费优惠券折扣金额
         */
        private String coupon_shipping_fee_amount;
        /**
         * 发货国家代码 (KR, CN, JP)
         */
        private String country_domain;
        /**
         * 收件人姓名
         */
        private String receiver_name;
        /**
         * 收件人姓名 2（运送至日本时必填）
         */
        private String receiver_name_voice;
        /**
         * 英文收件人姓名
         */
        private String receiver_name_eng;
        /**
         * 收件人座机
         */
        private String receiver_phone;
        /**
         * 收件人的手机号码
         */
        private String receiver_cell;
        /**
         * 收件人邮箱
         */
        private String receiver_email;
        /**
         * 收货邮政编码
         */
        private String receiver_zipcode;
        /**
         * 收货地址
         */
        private String receiver_address1;
        /**
         * 详细收货地址 1
         */
        private String receiver_address2;
        /**
         * 详细收货地址 2
         */
        private String receiver_address3;
        /**
         * 运费
         */
        private String ship_fee;
        /**
         * 运费预付 (T/F)
         */
        private String is_prepaid_ship_fee;
        /**
         * 发货信息
         */
        private String delivery_message;
        /**
         * 首选配送公司
         */
        private String want_deliverer;
        /**
         * 首选配送日期
         */
        private String want_date;
        /**
         * 首选配送时间
         */
        private String want_time;
        /**
         * 后付费（T/F）
         */
        private String is_postpaid;
        /**
         * 后付费实际支付金额
         */
        private String postpaid_actual_payment;
        /**
         * 后付费费用
         */
        private String postpaid_fee;
        /**
         * 后付费货币(KRW/USD/JPY/CNY)
         */
        private String postpaid_currency_code;
        /**
         * 订单路径
         */
        private String order_place_id;
        /**
         * 订单路径名称（如果 order_place_id 为自助服务代码，则为必填项）
         */
        private String order_place_name;
        /**
         * 其他市场信息
         */
        private String market_order_info;
        /**
         * 身份证
         */
        private String ship_identity;
        /**
         * 税务识别号
         */
        private String cdremark;
        /**
         * 是否使用出口报关（P/F）
         */
        private String resale_use_export_declare;
        /**
         * 出口申报标准金额（出口申报用途为 P 时必填）• 允许值：S/D
         */
        private String resale_declare_price_type;
        /**
         * 海关清关代码（出口报关用途为 P 时必填）海关清关代码
         */
        private String resale_customs_id;
        /**
         * 出口报关托运人信息邮政编码（出口报关用途为 P 时必填）邮政编码
         */
        private String resale_declare_zipcode;
        /**
         * 出口报关托运人信息地址（出口报关用途为 P 时必填）（韩语）
         */
        private String resale_declare_address1;
        /**
         * 出口报关托运人信息详细地址（出口报关用途为 P 时必填）详细地址（韩语）
         */
        private String resale_declare_address2;
        /**
         * 发件人姓名• 卖家名称或客户公司名称
         */
        private String resale_sender_name;
        /**
         * EMS 产品分类（内容类型）内容名称 • 如果为空，则在产品标题中存储第一个海关类别值。
         * 标签上的内容名称 *在快速包装盒中，EMS 发货时使用代表性内容名称。
         */
        private String resale_ems_goods_name;
        /**
         * EMS HS 编码• 如果为空，请填写产品标题中的第一个 HS 编码。
         * 签上的 HS 编码。*在 Fastbox 中，EMS 货件将使用对应的 HS 编码进行处理。
         */
        private String resale_ems_hscode;
        /**
         * EMS 发货地（输入国家/地区代码）• 如果为空，请保存为 KR
         */
        private String resale_ems_making_country;
        /**
         * 销售地点网址
         */
        private String resale_shop_url;
        /**
         * • 船运公司付款类型 (DDP/DDU)• 如果为空，则选择 DDP
         */
        private String resale_delivery_duty_type;

        private List<ItemBO> items;

        @Getter
        @ToString
        public static class ItemBO {
            /**
             * 卖家订单号
             */
            private String seller_ord_code;
            /**
             * 卖家商品编号
             */
            private String seller_ord_item_code;
            /**
             * 商店商品代码
             */
            private String item_code;
            /**
             * 商店产品代码
             */
            private String prd_code;
            /**
             * 商品条形码
             */
            private String item_barcode;
            /**
             * 产品名称
             */
            private String input_prd_name;
            /**
             * 商品名称
             */
            private String input_item_name;
            /**
             * 英文产品名称
             */
            private String prd_name_eng;
            /**
             * 产品材质（日本发货必填）
             */
            private String material;
            /**
             * 面料（日本发货必填）
             */
            private String cloth_material;
            /**
             * 数量
             */
            private String ord_qty;
            /**
             * 售价
             */
            private String selling_price;
            /**
             * 可选价格
             */
            private String option_price;
            /**
             * 产品折扣金额
             */
            private String discount_price;
            /**
             * 优惠券折扣金额（产品）
             */
            private String coupon_item_discount_price;
            /**
             * 应用产品折扣金额
             */
            private String app_item_discount_amount;
            /**
             * HS 编码
             */
            private String hs_code;
            /**
             * 公司产品名称
             */
            private String private_prd_name;
            /**
             * 公司产品名称
             */
            private String private_item_name;
            /**
             * 海关类别名称
             */
            private String prd_category;
            /**
             * 海关产品名称
             */
            private String prd_category_info;
            private String is_gift;
            private String item_location_code;
            private String seller_ord_item_no;

            public ItemBO setItem_barcode(String item_barcode) {
                this.item_barcode = item_barcode;
                return this;
            }

            public ItemBO setSeller_ord_code(String seller_ord_code) {
                this.seller_ord_code = seller_ord_code;
                return this;
            }

            public ItemBO setSeller_ord_item_code(String seller_ord_item_code) {
                this.seller_ord_item_code = seller_ord_item_code;
                return this;
            }

            public ItemBO setItem_code(String item_code) {
                this.item_code = item_code;
                return this;
            }

            public ItemBO setPrd_code(String prd_code) {
                this.prd_code = prd_code;
                return this;
            }

            public ItemBO setInput_prd_name(String input_prd_name) {
                this.input_prd_name = input_prd_name;
                return this;
            }

            public ItemBO setInput_item_name(String input_item_name) {
                this.input_item_name = input_item_name;
                return this;
            }

            public ItemBO setPrd_name_eng(String prd_name_eng) {
                this.prd_name_eng = prd_name_eng;
                return this;
            }

            public ItemBO setMaterial(String material) {
                this.material = material;
                return this;
            }

            public ItemBO setCloth_material(String cloth_material) {
                this.cloth_material = cloth_material;
                return this;
            }

            public ItemBO setOrd_qty(String ord_qty) {
                this.ord_qty = ord_qty;
                return this;
            }

            public ItemBO setSelling_price(String selling_price) {
                this.selling_price = selling_price;
                return this;
            }

            public ItemBO setOption_price(String option_price) {
                this.option_price = option_price;
                return this;
            }

            public ItemBO setDiscount_price(String discount_price) {
                this.discount_price = discount_price;
                return this;
            }

            public ItemBO setCoupon_item_discount_price(String coupon_item_discount_price) {
                this.coupon_item_discount_price = coupon_item_discount_price;
                return this;
            }

            public ItemBO setApp_item_discount_amount(String app_item_discount_amount) {
                this.app_item_discount_amount = app_item_discount_amount;
                return this;
            }

            public ItemBO setHs_code(String hs_code) {
                this.hs_code = hs_code;
                return this;
            }

            public ItemBO setPrivate_prd_name(String private_prd_name) {
                this.private_prd_name = private_prd_name;
                return this;
            }

            public ItemBO setPrivate_item_name(String private_item_name) {
                this.private_item_name = private_item_name;
                return this;
            }

            public ItemBO setPrd_category(String prd_category) {
                this.prd_category = prd_category;
                return this;
            }

            public ItemBO setPrd_category_info(String prd_category_info) {
                this.prd_category_info = prd_category_info;
                return this;
            }

            public ItemBO setIs_gift(String is_gift) {
                this.is_gift = is_gift;
                return this;
            }

            public ItemBO setItem_location_code(String item_location_code) {
                this.item_location_code = item_location_code;
                return this;
            }

            public ItemBO setSeller_ord_item_no(String seller_ord_item_no) {
                this.seller_ord_item_no = seller_ord_item_no;
                return this;
            }
        }

        public BO setSeller_name(String seller_name) {
            this.seller_name = seller_name;
            return this;
        }

        public BO setOrd_date(String ord_date) {
            this.ord_date = ord_date;
            return this;
        }

        public BO setOrd_bundle_no(String ord_bundle_no) {
            this.ord_bundle_no = ord_bundle_no;
            return this;
        }

        public BO setReference_order_no(String reference_order_no) {
            this.reference_order_no = reference_order_no;
            return this;
        }

        public BO setActual_payment(String actual_payment) {
            this.actual_payment = actual_payment;
            return this;
        }

        public BO setCurrency_code(String currency_code) {
            this.currency_code = currency_code;
            return this;
        }

        public BO setMembership_discount_amount(String membership_discount_amount) {
            this.membership_discount_amount = membership_discount_amount;
            return this;
        }

        public BO setCoupon_discount_price(String coupon_discount_price) {
            this.coupon_discount_price = coupon_discount_price;
            return this;
        }

        public BO setShipping_fee_discount_amount(String shipping_fee_discount_amount) {
            this.shipping_fee_discount_amount = shipping_fee_discount_amount;
            return this;
        }

        public BO setApp_discount_amount(String app_discount_amount) {
            this.app_discount_amount = app_discount_amount;
            return this;
        }

        public BO setPoints_spent_amount(String points_spent_amount) {
            this.points_spent_amount = points_spent_amount;
            return this;
        }

        public BO setFinal_points_spent_amount(String final_points_spent_amount) {
            this.final_points_spent_amount = final_points_spent_amount;
            return this;
        }

        public BO setCredits_spent_amount(String credits_spent_amount) {
            this.credits_spent_amount = credits_spent_amount;
            return this;
        }

        public BO setCoupon_shipping_fee_amount(String coupon_shipping_fee_amount) {
            this.coupon_shipping_fee_amount = coupon_shipping_fee_amount;
            return this;
        }

        public BO setCountry_domain(String country_domain) {
            this.country_domain = country_domain;
            return this;
        }

        public BO setReceiver_name(String receiver_name) {
            this.receiver_name = receiver_name;
            return this;
        }

        public BO setReceiver_name_voice(String receiver_name_voice) {
            this.receiver_name_voice = receiver_name_voice;
            return this;
        }

        public BO setReceiver_name_eng(String receiver_name_eng) {
            this.receiver_name_eng = receiver_name_eng;
            return this;
        }

        public BO setReceiver_phone(String receiver_phone) {
            this.receiver_phone = receiver_phone;
            return this;
        }

        public BO setReceiver_cell(String receiver_cell) {
            this.receiver_cell = receiver_cell;
            return this;
        }

        public BO setReceiver_email(String receiver_email) {
            this.receiver_email = receiver_email;
            return this;
        }

        public BO setReceiver_zipcode(String receiver_zipcode) {
            this.receiver_zipcode = receiver_zipcode;
            return this;
        }

        public BO setReceiver_address1(String receiver_address1) {
            this.receiver_address1 = receiver_address1;
            return this;
        }

        public BO setReceiver_address2(String receiver_address2) {
            this.receiver_address2 = receiver_address2;
            return this;
        }

        public BO setReceiver_address3(String receiver_address3) {
            this.receiver_address3 = receiver_address3;
            return this;
        }

        public BO setShip_fee(String ship_fee) {
            this.ship_fee = ship_fee;
            return this;
        }

        public BO setIs_prepaid_ship_fee(String is_prepaid_ship_fee) {
            this.is_prepaid_ship_fee = is_prepaid_ship_fee;
            return this;
        }

        public BO setDelivery_message(String delivery_message) {
            this.delivery_message = delivery_message;
            return this;
        }

        public BO setWant_deliverer(String want_deliverer) {
            this.want_deliverer = want_deliverer;
            return this;
        }

        public BO setWant_date(String want_date) {
            this.want_date = want_date;
            return this;
        }

        public BO setWant_time(String want_time) {
            this.want_time = want_time;
            return this;
        }

        public BO setIs_postpaid(String is_postpaid) {
            this.is_postpaid = is_postpaid;
            return this;
        }

        public BO setPostpaid_actual_payment(String postpaid_actual_payment) {
            this.postpaid_actual_payment = postpaid_actual_payment;
            return this;
        }

        public BO setPostpaid_fee(String postpaid_fee) {
            this.postpaid_fee = postpaid_fee;
            return this;
        }

        public BO setPostpaid_currency_code(String postpaid_currency_code) {
            this.postpaid_currency_code = postpaid_currency_code;
            return this;
        }

        public BO setOrder_place_id(String order_place_id) {
            this.order_place_id = order_place_id;
            return this;
        }

        public BO setOrder_place_name(String order_place_name) {
            this.order_place_name = order_place_name;
            return this;
        }

        public BO setMarket_order_info(String market_order_info) {
            this.market_order_info = market_order_info;
            return this;
        }

        public BO setShip_identity(String ship_identity) {
            this.ship_identity = ship_identity;
            return this;
        }

        public BO setCdremark(String cdremark) {
            this.cdremark = cdremark;
            return this;
        }

        public BO setResale_use_export_declare(String resale_use_export_declare) {
            this.resale_use_export_declare = resale_use_export_declare;
            return this;
        }

        public BO setResale_declare_price_type(String resale_declare_price_type) {
            this.resale_declare_price_type = resale_declare_price_type;
            return this;
        }

        public BO setResale_customs_id(String resale_customs_id) {
            this.resale_customs_id = resale_customs_id;
            return this;
        }

        public BO setResale_declare_zipcode(String resale_declare_zipcode) {
            this.resale_declare_zipcode = resale_declare_zipcode;
            return this;
        }

        public BO setResale_declare_address1(String resale_declare_address1) {
            this.resale_declare_address1 = resale_declare_address1;
            return this;
        }

        public BO setResale_declare_address2(String resale_declare_address2) {
            this.resale_declare_address2 = resale_declare_address2;
            return this;
        }

        public BO setResale_sender_name(String resale_sender_name) {
            this.resale_sender_name = resale_sender_name;
            return this;
        }

        public BO setResale_ems_goods_name(String resale_ems_goods_name) {
            this.resale_ems_goods_name = resale_ems_goods_name;
            return this;
        }

        public BO setResale_ems_hscode(String resale_ems_hscode) {
            this.resale_ems_hscode = resale_ems_hscode;
            return this;
        }

        public BO setResale_ems_making_country(String resale_ems_making_country) {
            this.resale_ems_making_country = resale_ems_making_country;
            return this;
        }

        public BO setResale_shop_url(String resale_shop_url) {
            this.resale_shop_url = resale_shop_url;
            return this;
        }

        public BO setResale_delivery_duty_type(String resale_delivery_duty_type) {
            this.resale_delivery_duty_type = resale_delivery_duty_type;
            return this;
        }

        public BO setItems(List<ItemBO> items) {
            this.items = items;
            return this;
        }
    }
}
